Repository navigation
Fix captured value-type index formatting in Blazor forms - #70429
Conversation
|
Thanks for your PR, @Yuvan111. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues with the captured value-type key formatting fix and its regression tests.
No open issues 🎉
What changed in this PR
Fixes Blazor form rendering failures when input expressions use captured value-type collection keys, such as long and Guid.
Changes:
- Adds an explicit conversion when a captured value type differs from the formatter’s expected return type, allowing boxing while preserving existing
intand reference-type paths. - Adds rendering regression tests that verify generated input IDs for captured
longandGuiddictionary keys.
| File | Description |
|---|---|
| src/Components/Web/test/Forms/InputTextTest.cs | Adds input ID regression tests for captured long and Guid keys. |
| src/Components/Shared/src/ExpressionFormatting/ExpressionFormatter.cs | Converts captured value types before constructing the evaluator lambda. |
Review effort: Balanced
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. Human-directed and GitHub Copilot-generated. |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
✅ No documentation PR was created. Confidence that documentation is needed: 5% No docs needed: bug fix for captured value-type index formatting in Blazor forms, with test-only additions. No signals detected. Documentation surfaces considered
|
Fix captured value-type index formatting in Blazor forms
Blazor inputs bound to captured value-type collection keys could throw during rendering. This affected keys such as
longandGuid. The fix allows these inputs to render normally.Root cause
The formatter builds a lambda that returns a formatting interface. Captured value types require an explicit boxing conversion. Without it, building the lambda throws an
ArgumentException.Solution
Convert value-type expressions to the expected return type when needed. This boxes the captured value before it is formatted. Existing
intand reference-type paths remain unchanged.Test coverage
longandGuidkeys.Fixes #70406